package com.uphone.kingmall.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.uphone.kingmall.app.MyApplication;

/**
 * @Author : 伊雅静
 * @Data : 2018/8/6 16:00
 * @Class : 封装SharedPreferences
 */
public class SharedPreferencesHelper {

    private static final String KEY_SPS_NAME = "SharedPreferences_name";
    private static final String KEY_UserId = "key_userId";
    private static final String KEY_UserInviteCode = "key_userInviteCode";
    private static final String KEY_MachCaptcha = "machCaptcha";
    private static final String KEY_TOKEN = "key_token";
    private static final String KEY_ARTICLE_ID = "key_articleId";
    private static final String KEY_USER_NAME = "key_userName";
    private static final String KEY_RY_TOKEN = "key_ryToken";
    private static final String KEY_USER_IMG = "key_userImg";
    private static final String KEY_USER_PHONE = "key_userPhone";
    private static final String KEY_SETTING_VOICE = "key_settingVoice";
    private static final String KEY_SETTING_SHOCK = "key_settingShock";
    private static final String KEY_SETTING_SYSTEM = "key_settingSystem";
    private static final String KEY_SHOP_STATUS = "KEY_ShopStatus";
    private static final String KEY_CITY = "KEY_City";


    private static SharedPreferences sp;

    static {
        sp = MyApplication.mContext.getSharedPreferences(KEY_SPS_NAME, Context.MODE_PRIVATE);
    }

    //--------------------UserID----------------------------------------
    public static void saveUserId(String userInfo) {
        sp.edit().putString(KEY_UserId, userInfo).apply();
    }


    public static String getUserId() {
        return sp.getString(KEY_UserId, null);
    }


    //--------------------InviteCode----------------------------------------
    public static void saveUserInviteCode(String inviteCode) {
        sp.edit().putString(KEY_UserInviteCode, inviteCode).apply();
    }


    public static String getUserInviteCode() {
        return sp.getString(KEY_UserInviteCode, null);
    }

    //--------------------machCaptcha----------------------------------------
    public static void saveMachCaptcha(String machCaptcha) {
        sp.edit().putString(KEY_MachCaptcha, machCaptcha).apply();
    }


    public static String getMachCaptcha() {
        return sp.getString(KEY_MachCaptcha, null);
    }


    //--------------------ArticleId----------------------------------------

    public static void saveArticleId(int ArticleId) {
        sp.edit().putInt(KEY_ARTICLE_ID, ArticleId).apply();
    }


    public static int getArticleId() {
        return sp.getInt(KEY_ARTICLE_ID, 0);
    }

    public static void clearArticleId() {
        sp.edit().remove(KEY_ARTICLE_ID);

    }
    //--------------------UserName----------------------------------------

    public static void saveUserName(String userName) {
        sp.edit().putString(KEY_USER_NAME, userName).apply();
    }


    public static String getUserName() {
        return sp.getString(KEY_USER_NAME, "");
    }

    //--------------------ShopStatus----------------------------------------

    public static void saveShopStatus(String shopStatus) {
        sp.edit().putString(KEY_SHOP_STATUS, shopStatus).apply();
    }


    public static String getShopStatus() {
        return sp.getString(KEY_SHOP_STATUS, "");
    }

    //--------------------RyToken融云Token----------------------------------------

    public static void saveRyToken(String ryToken) {
        sp.edit().putString(KEY_RY_TOKEN, ryToken).apply();
    }


    public static String getRyToken() {
        return sp.getString(KEY_RY_TOKEN, "");
    }

    //--------------------UserImg----------------------------------------
    public static void saveUserImg(String saveUserImg) {
        sp.edit().putString(KEY_USER_IMG, saveUserImg).apply();
    }

    public static String getUserImg() {
        return sp.getString(KEY_USER_IMG, "");
    }

    //--------------------UserPone----------------------------------------

    public static void saveUserPhone(String phone) {
        sp.edit().putString(KEY_USER_PHONE, phone).apply();
    }


    public static String getUserPhone() {
        return sp.getString(KEY_USER_PHONE, "");
    }

    //--------------------SettingVoice----------------------------------------

    public static void saveSettingVoice(String voice) {
        sp.edit().putString(KEY_SETTING_VOICE, voice).apply();
    }


    public static String getSettingVoice() {
        return sp.getString(KEY_SETTING_VOICE, "");
    }

    //--------------------SettingShock----------------------------------------

    public static void saveSettingShock(String shock) {
        sp.edit().putString(KEY_SETTING_SHOCK, shock).apply();
    }


    public static String getSettingShock() {
        return sp.getString(KEY_SETTING_SHOCK, "");
    }

    //--------------------SettingSystem----------------------------------------

    public static void saveSettingSystem(String system) {
        sp.edit().putString(KEY_SETTING_SYSTEM, system).apply();
    }


    public static String getSettingSystem() {
        return sp.getString(KEY_SETTING_SYSTEM, "");
    }

    //--------------------City----------------------------------------

    public static void saveCity(String city) {
        sp.edit().putString(KEY_CITY, city).apply();
    }


    public static String getCity() {
        return sp.getString(KEY_CITY, "");
    }


    //--------------------Token----------------------------------------

    public static void saveToken(String carnum) {
        sp.edit().putString(KEY_TOKEN, carnum).apply();
    }

    public static String getToken() {
        return sp.getString(KEY_TOKEN, "");
    }

    public static void clearTokenAndUserId() {
        sp.edit().clear().apply();
    }
}
